


package yf.mall.controller;
import com.yf.request.SearchParam;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import yf.mall.vo.MallCardVo;
import yf.mall.service.MallCardService;
import com.yf.response.R;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
                        
/**
 * Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Thu Sep 10 13:15:02 CST 2020
 */
@RestController
@RequestMapping("/mall/card")
public class MallCardController {
    @Autowired
    private MallCardService mallCardService;

    /**
     * 列表
     */
    @SysLog("查看")
    @RequestMapping("/dmz/list")
    @RequiresPermissions("mall:card:list")
    public R list(@RequestBody(required = false) SearchParam<MallCardVo> params) {
//        PageHelper.startPage(params.getPage(), params.getLimit()).setOrderBy(params.getOrder());
        List<MallCardVo> list = mallCardService.findVo(null);
        return R.ok(new PageInfo(list));
    }

    /**
 * 下载订单
 */
    @SysLog("下载订单")
    @RequestMapping("/down")
    @RequiresPermissions("mall:card:list")
    public void down(@RequestBody SearchParam<MallCardVo> params, HttpServletResponse response) {
        List<MallCardVo> list = mallCardService.findVo(params.getEntity());
            mallCardService.downLoad(response, list);
    }


    /**
     * 查看
     */
    @SysLog("查看")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("mall:card:info")
    public R info(@PathVariable("id") Long id) {
            MallCardVo vo = mallCardService.getVo(id);

        return R.ok(vo);
    }

    /**
     * 保存
     */
    @SysLog("保存")
    @RequestMapping("/save")
    @RequiresPermissions("mall:card:save")
    public R save(@RequestBody MallCardVo vo) {
            mallCardService.saveVo(vo);
        return R.ok(vo);
    }

    /**
     * 修改
     */
    @SysLog("修改")
    @RequestMapping("/update")
    @RequiresPermissions("mall:card:update")
    public R update(@RequestBody MallCardVo vo) {
            mallCardService.updateVo(vo);

        return R.ok(vo);
    }

    /**
     * 删除
     */
    @SysLog("删除")
    @RequestMapping("/delete")
    @RequiresPermissions("mall:card:delete")
    public R delete(Long[]ids) {
            mallCardService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有
     */
    @SysLog("所有")
    @RequestMapping("/all")
    public R all(String order) {
        PageHelper.orderBy(order!=null ? order : "id desc");
        List<MallCardVo> list = mallCardService.findVo(null);
        return R.ok(list);
    }

    /**
     * 所有enums
     */
    @SysLog("所有enums")
    @RequestMapping("/dmz/options")
    public R options() {
        HashMap<String,Object> options = new HashMap();
                                                                                                                                        return R.ok(options);
    }





    /***********自定义开始***********/
}
